<script setup lang="ts">
import { reactive, ref } from "vue";
import CountUp from "../components2/count-up/count-up.vue";
import {ElMessage} from "element-plus"

const duration = ref(2);
const state = reactive({
  targetCount: 0,
  totalCount: 0,
  okCount: 0,
  ngCount: 0,
});


const getData = () => {
  // countDeviceNum().then((res) => {
  //   console.log("左上--设备总览",res);
  //   if (res.success) {
      state.targetCount = 1000;
      state.totalCount = 800;
      state.okCount = 710;
      state.ngCount = 90;
    // }else{
    //   ElMessage.error(res.msg)
    // }
  // }).catch(err=>{
  //   ElMessage.error(err)
  // });;
};
getData();
</script>

<template>
  <ul class="user_Overview flex" style="justify-content: center;align-items: center;">
    <li class="user_Overview-item" style="color: #00fdfa">
      <div class="user_Overview_nums allnum">
        <CountUp :endVal="state.targetCount" :duration="duration" />
      </div>
      <p>目标产能</p>
    </li>
    <li class="user_Overview-item" style="color: #e3b337">
      <div class="user_Overview_nums offline">
        <CountUp :endVal="state.totalCount" :duration="duration" />
      </div>
      <p>实际产能（总）</p>
    </li>
    <li class="user_Overview-item" style="color: #07f7a8">
      <div class="user_Overview_nums online">
        <CountUp :endVal="state.okCount" :duration="duration" />
      </div>
      <p>实际产能(OK)</p>
    </li>
    <li class="user_Overview-item" style="color: #f5023d">
      <div class="user_Overview_nums laramnum">
        <CountUp :endVal="state.ngCount" :duration="duration" />
      </div>
      <p>实际产能(NG)</p>
    </li>
  </ul>
</template>

<style scoped lang="scss">
.left-top {
  width: 100%;
  height: 100%;
}

.user_Overview {
  li {
    flex: 1;

    p {
      text-align: center;
      height: 16px;
      font-size: 16px;
    }

    .user_Overview_nums {
      width: 100px;
      height: 100px;
      text-align: center;
      line-height: 100px;
      font-size: 22px;
      margin: 50px auto 30px;
      background-size: cover;
      background-position: center center;
      position: relative;

      &::before {
        content: "";
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
      }

      &.bgdonghua::before {
        animation: rotating 14s linear infinite;
      }
    }

    .allnum {
      &::before {
        background-image: url("@/assets/images/left_top_lan.png");
      }
    }

    .online {
      &::before {
        background-image: url("@/assets/images/left_top_lv.png");
      }
    }

    .offline {
      &::before {
        background-image: url("@/assets/images/left_top_huang.png");
      }
    }

    .laramnum {
      &::before {
        background-image: url("@/assets/images/left_top_hong.png");
      }
    }
  }
}
</style>
